<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>react-toggle</title>
</head>
<style>
    img{
        width: 20px;
    }
</style>

<body>
    <div id="root"></div>
</body>
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
<script type="text/babel">
    class Toggle extends React.Component {
        constructor(props) {
            super(props);
            this.state = {
                toggle: true
            }
        }

        setToggle() {
            this.setState({
                toggle: !this.state.toggle
            })
        }

        render() {
            return (
                <div>
                    <h1>Hello, world!</h1>
                    <button onClick={() => this.setToggle()}>{this.state.toggle === true ? 'ON' : 'OFF'}</button>
                </div>
            );
        }
    }

    ReactDOM.render(
        <Toggle />,
        document.getElementById('root')
    );

</script>

</html>